package com.ruoyi.web.controller.qif;

import java.util.List;

import com.ruoyi.qif.service.IQifRoomService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.qif.domain.QifGuest;
import com.ruoyi.qif.service.IQifGuestService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 锜风公寓-房间住客Controller
 *
 * @author David
 * @date 2025-10-05
 */
@Controller
@RequestMapping("/qif/guest")
public class QifGuestController extends BaseController {
    private String prefix = "qif/guest";

    @Autowired
    private IQifGuestService qifGuestService;
    @Autowired
    private IQifRoomService qifRoomService;

    @RequiresPermissions("qif:guest:view")
    @GetMapping()
    public String guest() {
        return prefix + "/guest";
    }

    /**
     * 查询锜风公寓-房间住客列表
     */
    @RequiresPermissions("qif:guest:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(QifGuest qifGuest) {
        startPage();
        List<QifGuest> list = qifGuestService.selectQifGuestList(qifGuest);
        return getDataTable(list);
    }

    /**
     * 导出锜风公寓-房间住客列表
     */
    @RequiresPermissions("qif:guest:export")
    @Log(title = "锜风公寓-房间住客", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(QifGuest qifGuest) {
        List<QifGuest> list = qifGuestService.selectQifGuestList(qifGuest);
        ExcelUtil<QifGuest> util = new ExcelUtil<QifGuest>(QifGuest.class);
        return util.exportExcel(list, "锜风公寓-房间住客数据");
    }

    /**
     * 新增锜风公寓-房间住客
     */
    @RequiresPermissions("qif:guest:add")
    @GetMapping("/add/{roomId}")
    public String add(@PathVariable("roomId") Long roomId, ModelMap mmap){
        mmap.put("room", qifRoomService.selectQifRoomByRoomId(roomId));
        return prefix + "/add";
    }

    /**
     * 新增保存锜风公寓-房间住客
     */
    @RequiresPermissions("qif:guest:add")
    @Log(title = "锜风公寓-房间住客", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(QifGuest qifGuest) {
        return toAjax(qifGuestService.insertQifGuest(qifGuest));
    }

    /**
     * 修改锜风公寓-房间住客
     */
    @RequiresPermissions("qif:guest:edit")
    @GetMapping("/edit/{guestId}")
    public String edit(@PathVariable("guestId") Long guestId, ModelMap mmap) {
        QifGuest qifGuest = qifGuestService.selectQifGuestByGuestId(guestId);
        mmap.put("qifGuest", qifGuest);
        return prefix + "/edit";
    }

    /**
     * 修改保存锜风公寓-房间住客
     */
    @RequiresPermissions("qif:guest:edit")
    @Log(title = "锜风公寓-房间住客", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(QifGuest qifGuest) {
        return toAjax(qifGuestService.updateQifGuest(qifGuest));
    }

    /**
     * 删除锜风公寓-房间住客
     */
    @RequiresPermissions("qif:guest:remove")
    @Log(title = "锜风公寓-房间住客", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(qifGuestService.deleteQifGuestByGuestIds(ids));
    }
}
